package com.cgq.pro.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cgq.base.service.impl.BaseServiceImpl;
import com.cgq.pro.dao.LandDao;
import com.cgq.pro.dao.RegionDao;
import com.cgq.pro.entity.Land;
import com.cgq.pro.entity.LandForm;
import com.cgq.pro.entity.Region;
import com.cgq.pro.service.LandService;
import com.cgq.utils.PropertiesUtil;

@Service
public class LandServiceImpl extends BaseServiceImpl<Land> implements LandService {

	private LandDao landDao;
	
	@Autowired
	private RegionDao regionDao;
	@Autowired
	public void setLandDao(LandDao dao)
	{
		this.baseDao=dao;
		this.landDao=dao;
		
	}

	public Map getLandUseType() {
		Map useMap = new HashMap();
		try{
		   int total=Integer.parseInt(PropertiesUtil.readByKey("landUseType", "totalType"));
		  
		   for(int i=1;i<=total;i++){
			 String key=PropertiesUtil.readByKey("landUseType", "type."+i);
			 useMap.put(i, key);
		   }
		}catch(Exception e)
		{
			e.printStackTrace();
		}
		return useMap;
	}

	public Map getArea() {
		Map map=new HashMap();
		List<Region> list = regionDao.findAll();
		for(int i=0;i<list.size();i++){
		  Region region=list.get(i);
		  map.put(region.getId(), region.getName());
		}
		return map;
	}
	
	public int getTotal(Map<String, String> map,int type) {
		return landDao.getTotal(map,type);
	}
	
	public List<Land> getAllRecords(int start, int pageSize,Map<String,String> map,int  type){
		return landDao.getAllRecords(start,pageSize,map,type);
	}
	
	public List<Land> getAllRecords(LandForm landForm){
		return landDao.getAllRecords(landForm);
	}


}
